EMMA Coverage Report (generated Sat Sep 03 18:56:48 CEST 2016)
[all classes][kdk.android.simplydo]

COVERAGE SUMMARY FOR SOURCE FILE [ListListSorter.java]

nameclass, %method, %block, %line, %
ListListSorter.java100% (3/3)100% (7/7)89%  (95/107)96%  (22/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListListSorter100% (1/1)100% (3/3)86%  (71/83)95%  (20/21)
sort (List): void 100% (1/1)57%  (16/28)86%  (6/7)
ListListSorter (): void 100% (1/1)100% (15/15)100% (4/4)
setSortingMode (String): void 100% (1/1)100% (40/40)100% (10/10)
     
class ListListSorter$1100% (1/1)100% (2/2)100% (12/12)100% (2/2)
ListListSorter$1 (ListListSorter): void 100% (1/1)100% (6/6)100% (1/1)
compare (ListDesc, ListDesc): int 100% (1/1)100% (6/6)100% (1/1)
     
class ListListSorter$2100% (1/1)100% (2/2)100% (12/12)100% (2/2)
ListListSorter$2 (ListListSorter): void 100% (1/1)100% (6/6)100% (1/1)
compare (ListDesc, ListDesc): int 100% (1/1)100% (6/6)100% (1/1)

1/*
2 * Copyright (C) 2010 Keith Kildare
3 * 
4 * This file is part of SimplyDo.
5 * 
6 * SimplyDo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * 
11 * SimplyDo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 * 
16 * You should have received a copy of the GNU General Public License
17 * along with SimplyDo.  If not, see <http://www.gnu.org/licenses/>.
18 * 
19 */
20package kdk.android.simplydo;
21 
22import java.util.Collections;
23import java.util.Comparator;
24import java.util.List;
25 
26import android.util.Log;
27 
28public class ListListSorter
29{
30    public static final String PREF_NONE = "none";
31    public static final String PREF_ALPHA = "alphabetical";
32    
33    private static final int NONE = 0;
34    private static final int ALPHA = 1;
35    
36    private int sortingMode;
37    
38    private Comparator<ListDesc> idCompare;
39    private Comparator<ListDesc> alphaCompare;
40    
41    
42    public ListListSorter()
43    {
44        idCompare = new Comparator<ListDesc>() {
45            @Override
46            public int compare(ListDesc object1, ListDesc object2)
47            {
48                return object2.getId() - object1.getId();
49            }
50        };
51        alphaCompare = new Comparator<ListDesc>() {
52            @Override
53            public int compare(ListDesc object1, ListDesc object2)
54            {
55                return object1.getLabel().compareToIgnoreCase(object2.getLabel());
56            }
57        };
58    }
59    
60    
61    public void setSortingMode(String mode)
62    {
63        if(PREF_NONE.equals(mode))
64        {
65                System.out.println("1");
66            sortingMode = NONE;
67        }
68        else if(PREF_ALPHA.equals(mode))
69        {
70                System.out.println("2");
71            sortingMode = ALPHA;
72        }
73        else
74        {
75                System.out.println("3");
76 
77            sortingMode = NONE;
78            Log.w(L.TAG, "Unknown list sorting mode " + mode);
79        }
80    }
81    
82    
83    public void sort(List<ListDesc> list)
84    {
85            System.out.println("world3");
86        switch(sortingMode)
87        {
88        default:
89            Log.w(L.TAG, "Unknown list sorting enum " + sortingMode);
90            // fall through
91        case NONE:
92            // actually sorted by db id
93            Collections.sort(list, idCompare);
94            break;
95        case ALPHA:
96            Collections.sort(list, alphaCompare);
97            break;
98        }
99    }
100}

[all classes][kdk.android.simplydo]
EMMA 2.0.5312 (C) Vladimir Roubtsov